package com.zx.idc.backend.gui.api.ftp;

import org.apache.commons.net.ftp.FTP;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * sftp 的客户端配置
 *
 * @author rxliuli
 */
@ConfigurationProperties(prefix = "ftp")
@Component("ftpClientConfig")
public class FtpClientConfig extends BaseFtpClientConfig {
    /*****sftp config start*****/
    public static final String DEFAULT_STRICT_HOST_KEY_CHECKING = "no";
    public static final String DEFAULT_ENCODING = "UTF-8";
    /**
     * 是否进行严格 RSA 密钥检查，默认使用密码登录所以不检查
     */
    private String strictHostKeyChecking = DEFAULT_STRICT_HOST_KEY_CHECKING;
    /**
     * sftp 发送命令的编码格式，默认全局使用 UTF-8（最广泛也最安全）
     */
    private String encoding = DEFAULT_ENCODING;

    /******sftp config end*****/

    /******ftp config start******/
    /**
     * 本地字符集的字符集，默认为 GBK
     */
    public static final String DEFAULT_LOCAL_CHARSET = "ISO-8859-1";
    /**
     * 服务器字符集，默认为 ISO-8859-1
     */
    public static final String DEFAULT_SERVER_CHARSET = "GBK";
    /**
     * 文件传输形式，默认以二进制流传输
     */
    public static final int DEFAULT_FILE_TYPE = FTP.BINARY_FILE_TYPE;
    /**
     * 本地字符集的字符集，默认为 GBK
     */
    private String localCharset = DEFAULT_LOCAL_CHARSET;
    /**
     * 服务器字符集，默认为 ISO-8859-1
     */
    private String serverCharset = DEFAULT_SERVER_CHARSET;
    /**
     * 文件传输形式，默认以二进制流传输
     */
    private Integer fileType = DEFAULT_FILE_TYPE;

    /**
     * 连接数初始化
     */
    private Integer initConnections=1;

    /******ftp config end******/


    public FtpClientConfig() {

    }


    public FtpClientConfig(String username, String host, String password, Integer port, String basePath) {
        super(username, host, password, port, basePath);
    }

    public FtpClientConfig(String username, String host, String password, Integer port) {
        super(username, host, password, port, BaseFtpClientConfig.DEFAULT_BASE_PATH);
    }

    public String getStrictHostKeyChecking() {
        return strictHostKeyChecking;
    }

    public FtpClientConfig setStrictHostKeyChecking(String strictHostKeyChecking) {
        this.strictHostKeyChecking = strictHostKeyChecking;
        return this;
    }

    public String getEncoding() {
        return encoding;
    }

    public FtpClientConfig setEncoding(String encoding) {
        this.encoding = encoding;
        return this;
    }

    public String getLocalCharset() {
        return localCharset;
    }

    public FtpClientConfig setLocalCharset(String localCharset) {
        this.localCharset = localCharset;
        return this;
    }

    public String getServerCharset() {
        return serverCharset;
    }

    public FtpClientConfig setServerCharset(String serverCharset) {
        this.serverCharset = serverCharset;
        return this;
    }

    public Integer getFileType() {
        return fileType;
    }

    public FtpClientConfig setFileType(Integer fileType) {
        this.fileType = fileType;
        return this;
    }

    public Integer getInitConnections() {
        return initConnections;
    }

    public FtpClientConfig setInitConnections(Integer initConnections) {
        this.initConnections = initConnections;
        return this;
    }
}
